Skip to content

Testing works #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Conversation

danielballan
Copy link
Contributor

@danielballan danielballan commented May 12, 2025

This reworks the test script from my sketch to incorporate nbval.

As the output shows, this:

  1. Converts text-based notebooks to ipynb and accumulates an array of the files it has written.
  2. Runs pytest --nbval
  3. Cleans up the files it created (but not any existing ipynb files that it did not write)

Usage:

❯ ./test.sh
Usage: ./test.sh [filepaths...] | --all

Test all:

❯ ./test.sh --all
[jupytext] Reading tutorials/executable/basics.md in format md
[jupytext] Writing tutorials/executable/basics.ipynb
[jupytext] Reading tutorials/matplotlib/static_mpl.md in format md
[jupytext] Writing tutorials/matplotlib/static_mpl.ipynb
[jupytext] Reading tutorials/matplotlib/interactive_mpl.md in format md
[jupytext] Writing tutorials/matplotlib/interactive_mpl.ipynb
====================== test session starts =======================
platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0
rootdir: /home/dallan/Repos/bnl/executable-tutorials
plugins: anyio-4.9.0, nbval-0.11.0
collected 12 items

tutorials/executable/basics.ipynb ....                     [ 33%]
tutorials/matplotlib/interactive_mpl.ipynb .....           [ 75%]
tutorials/matplotlib/static_mpl.ipynb ...                  [100%]

======================= 12 passed in 3.09s =======================
removed 'tutorials/executable/basics.ipynb'
removed 'tutorials/matplotlib/static_mpl.ipynb'
removed 'tutorials/matplotlib/interactive_mpl.ipynb'
All files executed successfully.

Test one or more. This can in a future PR be given a list of changed tutorials to be selectively run.

❯ ./test.sh tutorials/executable/basics.md
[jupytext] Reading tutorials/executable/basics.md in format md
[jupytext] Writing tutorials/executable/basics.ipynb
====================== test session starts =======================
platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0
rootdir: /home/dallan/Repos/bnl/executable-tutorials
plugins: anyio-4.9.0, nbval-0.11.0
collected 4 items

tutorials/executable/basics.ipynb ....                     [100%]

======================= 4 passed in 0.88s ========================
removed 'tutorials/executable/basics.ipynb'
All files executed successfully.

@bsipocz
Copy link
Member

bsipocz commented May 12, 2025

Test one or more. This can in a future PR be given a list of changed tutorials to be selectively run.

I have that all set up, let me open the PR

@bsipocz
Copy link
Member

bsipocz commented May 13, 2025

#44 overtook this

@bsipocz bsipocz closed this May 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants